<script setup lang="ts">
import BorderBox13 from "@/components/datav/border-box-13";
import { ElButton } from "element-plus";
import { ref } from "vue";

const props = withDefaults(
  defineProps<{
    title: number | string;
  }>(),
  {
    title: "",
  }
);

const activeButton = ref("项目类型"); // 默认选中的按钮
const selectButton = (button: string) => {
  activeButton.value = button;
};
</script>

<template>
  <BorderBox13>
    <div class="item_title" v-if="title !== ''">
      <div class="zuo">
        <img class="xmimg" src="@/assets/leixing.png" alt="xm" />
      </div>
      <span class="title-inner">&nbsp;&nbsp;{{ title }}&nbsp;&nbsp;</span>
    </div>
    <div class="button-change">
      <el-button-group class="button-groupS">
        <el-button
          :class="{ active: activeButton === '项目类型' }"
          @click="selectButton('项目类型')"
          type="primary"
          plain
        >
          项目类型
        </el-button>
        <el-button
          :class="{ active: activeButton === '内部项目类型' }"
          @click="selectButton('内部项目类型')"
          type="primary"
          plain
        >
          内部项目类型
        </el-button>
      </el-button-group>
    </div>

    <div
      :class="title !== '' ? 'item_title_content' : 'item_title_content_def'"
    >
      <slot></slot>
    </div>
  </BorderBox13>
</template>

<style scoped lang="scss">
$item-title-height: 38px;
$item_title_content-height: calc(100% - 38px);

.button-change {
  display: flex;
  justify-self: end;
  position: relative;
  top: -23px; /* 向上移动5px */
}

.xmimg {
  position: absolute;
  top: 65%;
  left: 6%;
}

.item_title {
  height: $item-title-height;
  line-height: $item-title-height;
  width: 100%;
  color: #31abe3;
  text-align: center;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;

  .zuo,
  .you {
    width: 58px;
    height: 14px;
  }
  .you {
    transform: rotate(180deg);
  }
  .title-inner {
    position: absolute;
    top: 50%;
    left: 8%;
    font-weight: 900;
    font-size: 20px;
    letter-spacing: 2px;
    background-color: #333;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-right: 222px;
  }
}

:deep(.dv-border-box-content) {
  box-sizing: border-box;
  padding: 6px 16px 0px;
}

.item_title_content {
  height: $item_title_content-height;
}

.item_title_content_def {
  width: 100%;
  height: 100%;
}

.button-change .el-button {
  z-index: 10;
  border-color: red;
  color: red;
  background-color: white;
}

.button-change .el-button.active {
  background-color: red;
  color: white;
}
.el-button-group.button-groupS {
    margin-left: 580px;
}
</style>
